﻿using System;

using System.Collections.Generic;
using System.Text;

namespace Silvermoon.Animations
{
    /// <summary>
    /// Ease function that returns only two values 0.0f and 1.0f depending on a Thresold.
    /// </summary>
    public class TriggerEase : EasingFunctionBase
    {
        private float threshold = 0.5f;
        private static TriggerEase instance;

        public static TriggerEase Instance
        {
            get
            {
                if (instance == null) instance = new TriggerEase();
                return instance;
            }
        }

        /// <summary>
        /// Threshold when to change from 0 to 1. The default value is 0.5f.
        /// </summary>
        public float Threshold
        {
            get { return threshold; }
            set
            {
                if (value < 0.0f) value = 0.0f;
                else if (value > 1.0f) value = 1.0f;
                threshold = value;
            }
        }

        protected override float EaseValue(float normalizedTime)
        {
            return normalizedTime < threshold ? 0.0f : 1.0f;
        }
    }
}
